package cn.gson.work.controller;

import cn.gson.work.model.pojos.Category;
import cn.gson.work.model.pojos.Project;
import cn.gson.work.model.pojos.User;
import cn.gson.work.model.service.ProjectsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Controller
public class ProjectController {
    @Autowired
    ProjectsService service;
    @GetMapping("/All")
    @ResponseBody
    public List<Project> All(String  USER_NAME){
        return service.All(USER_NAME);
    }
    @GetMapping("/cate")
    @ResponseBody
    public List<Category> cate(){
        return service.cate();
    }
    @PostMapping("/addP")
    @ResponseBody
    public void addp(@RequestBody Project project){
        service.addP(project);
    }
    @GetMapping("/man")
    @ResponseBody
    public List<User> man(){
        return service.man();
    }

    @RequestMapping("/dh")
    @ResponseBody
    public String getOrderIdByTime() {
        SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmss");
        String newDate=sdf.format(new Date());
        String result="";
//        Random random=new Random();
//        for(int i=0;i<3;i++){
//            result+=random.nextInt(10);
//        }
        String dh="HM"+newDate;
        return dh;
    }
}
